#pragma once

#include <iostream>
#include <functional>
#include <vector>
using namespace std;

//typedef void (*task_t)();
using task_func = std::function<void()>;


class task_list
{
public:
    int insert(task_func func)
    {
        _tasks.push_back(func);
        return _tasks.size() - 1;
    }

    void execute(int task_code)
    {
        if(task_code < 0 || task_code >= _tasks.size())
        {
            cout << "任务码错误, 任务不存在 - " << _tasks.size() << endl;
        }
        _tasks[task_code]();//执行任务
    }


private:
    vector<task_func> _tasks;
};